pub struct Solution;

impl Solution {
    pub fn capitalize_title(title: String) -> String {
        title
            .split(" ")
            .into_iter()
            .fold(String::new(), |mut acc, v| {
                let mut word = v.to_lowercase();
                if word.len() >= 3 {
                    let tuple = word.split_at(1);
                    let mut tmp = tuple.0.to_uppercase();
                    tmp.push_str(tuple.1.as_ref());
                    word = tmp;
                }
                acc.push_str(format!("{} ", word).as_str());
                acc
            }).trim_end().to_string()
    }
}


#[test]
pub fn test() {
    assert_eq!(Solution::capitalize_title("capiTalIze tHe titLe".to_string()), "Capitalize The Title".to_string());
}